home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Language/OS - Multiplatform Resource Library
/
LANGUAGE OS.iso
/
smaltalk
/
st80_pr4.lha
/
st80_pre4
/
MoDE
/
Scroll-Shan.st
< prev
next >
Wrap
Text File
|
1993-07-24
|
9KB
|
313 lines
SemanticObject subclass: #RoamBox
instanceVariableNames: 'marker updateStyle '
classVariableNames: ''
poolDictionaries: ''
category: 'Scroll-Shan'!
!RoamBox methodsFor: 'private'!
extent: ext clientMode: aMode
"Shan September 11, 1989"
aMode semanticObject notNil
ifTrue: ["Use semanticObject as a connection point is the standard
way. "
target1 _ aMode semanticObject]
ifFalse: [target1 _ aMode].
mode extent: ext.
self checkMarkerSizeAndPosition.
self clientMode addDependent: self! !
!RoamBox methodsFor: 'MMS-initializations'!
setUpAppearance
"Shan June 20, 1989"
| dispObj |
super setUpAppearance. "Shan July 21, 1989"
dispObj _ mode displayObject.
dispObj borderWidth: 2.
dispObj insideColor: Form white!
setUpController
"Shan June 23, 1989"
| ctrl erDict |
ctrl _ OpaqueController1 new.
erDict _ ctrl eventResponses deepCopy.
erDict at: #enterMode put: #refresh:.
ctrl eventResponses: erDict.
mode controller: ctrl! !
!RoamBox methodsFor: 'initialize-release'!
initialize
"Shan July 12, 1989"
super initialize.
updateStyle _ #discrete.
"Shan September 11, 1989"
marker _ Marker new.
marker attachModeTo: mode at: 5@5 extent: 40@30.!
release
self clientMode removeDependent: self.
super release! !
!RoamBox methodsFor: 'scrolling'!
checkMarkerSizeAndPosition
"This will set the marker size to reflect the ratio between the client
mode window and the client mode roaming region. Shan June 23, 1989"
| ratio mOrg mExt cBoundBox clientM cWindow insetExt |
insetExt _ mode window extent - (mode borderWidth * 2).
clientM _ self clientMode.
"For mode composer. Shan September 11, 1989"
clientM isNil
ifTrue: [mExt _ marker mode extent. mOrg _ marker mode origin]
ifFalse:
["insetExt _ mode insetDisplayBox extent."
cBoundBox _ clientM contentsBoundingBox.
cWindow _ clientM window.
ratio _ insetExt / cBoundBox extent.
mOrg _ (cWindow origin - cBoundBox origin * ratio) rounded.
"Adjust the position"
mOrg _ mOrg + mode borderWidth.
mExt _ (cWindow extent * ratio) rounded].
"Make it fit into the movable area."
mExt _ mExt min: insetExt.
"See if self is a roamBox or scroll bar."
mode displayBox width / mode displayBox height > 3
ifTrue:
["horizontal scrollbar"
mExt _ mExt y: insetExt y.
mOrg y: mode borderWidth]
ifFalse: [mode displayBox height / mode displayBox width > 3
ifTrue:
["vertical scrollbar"
mExt _ mExt x: insetExt x.
mOrg x: mode borderWidth]].
(mOrg extent: mExt)
= marker mode viewport
ifTrue: ["No change"
^false]
ifFalse:
[marker mode origin: mOrg extent: mExt.
^true]!
markerMovedTo: aRect
"The marker has moved. Scroll the client accordingly. The scroll bar
is implemented as it is for roaming and then spefialized for horizontal
and vertical scroll. Shan June 23, 1989"
| insetDispB ratio clientM clientW cBoundBox newOrg |
clientM _ self clientMode.
"For mode composer. Shan September 11, 1989"
clientM isNil ifTrue: [^self].
insetDispB _ mode insetDisplayBox.
clientW _ clientM window.
cBoundBox _ clientM contentsBoundingBox.
"Compute the ratio to scroll"
ratio _ aRect origin - insetDispB origin / insetDispB extent.
newOrg _ (cBoundBox extent * ratio) rounded + cBoundBox origin.
"The size of the client window is not going to change when scrolling."
"See if self is a roamBox or scroll bar."
mode displayBox width / mode displayBox height > 3
ifTrue: ["horizontal scrollbar"
newOrg y: clientW top]
ifFalse: [mode displayBox height / mode displayBox width > 3 ifTrue: ["vertical scrollbar"
newOrg x: clientW left]].
clientW _ clientW moveTo: newOrg.
"Check to see whether the window is moved or not. Shan July 12,
1989 "
clientW = clientM window ifTrue: [^self].
clientM window: clientW viewport: clientM viewport.
clientM computeSubLayering.
updateStyle == #discrete ifTrue: [Cursor wait show].
clientM insideColor isNil ifTrue: [clientM erase].
clientM display.
updateStyle == #discrete ifTrue: [Cursor normal show]! !
!RoamBox methodsFor: 'controller-msg'!
processCursorMove: e
"This is to update the scrolled mode continuously. Shan July 12,
1989"
updateStyle ~~ #continuous ifTrue: [^self].
"The offset between the origin of the rubber frame and the cursorPt
is stored in e data offset. Shan July 16, 1989"
self markerMovedTo: (e origin - e data offset extent: marker mode displayBox extent)!
refresh: e
"Update the size and position of the marker when the cursor first
enters the scroll bar. Shan June 23, 1989"
self checkMarkerSizeAndPosition ifTrue: [mode display]! !
!RoamBox methodsFor: 'access'!
clientMode
"Shan September 11, 1989"
target1 isNil
ifTrue: [^nil]
ifFalse: ["target1 has to be either Mode or SemanticObject."
(target1 isKindOf: Mode)
ifTrue: [^target1]
ifFalse: [^target1 mode]]!
updateStyle: aSymbol
"aSymbol can be either #discrete or #continuous. Shan July 12,
1989 "
updateStyle _ aSymbol! !
!RoamBox methodsFor: 'updating'!
update: x
"This is sent when the marker size and position is possibly out of date.
The occations are: client adds/removes subModes, subModes of the
client moves. Shan June 23, 1989"
x = #contentsBoundingBoxMayBeChanged ifTrue: [self checkMarkerSizeAndPosition ifTrue: [mode display]]! !
!RoamBox methodsFor: 'drag support'!
dragControllerFor: aSymbol
"Return a Controller that is sensitive to cursorMove Event. It is use to continuously update the scrolled mode. Shan July 11, 1989"
| ctrl erDict |
ctrl _ OpaqueController1 new.
erDict _ ctrl eventResponses deepCopy.
erDict at: #cursorMove put: #processCursorMove:.
ctrl eventResponses: erDict.
^ctrl! !
"-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- "!
RoamBox class
instanceVariableNames: ''!
!RoamBox class methodsFor: 'instance creation'!
extent: ext clientMode: aMode
"The client must be a mode. Shan September 11, 1989"
^self new extent: ext clientMode: aMode! !
!RoamBox class methodsFor: 'memory management'!
private
"Shan June 23, 1989"
"RoamBox allInstances do: [: each | each nilFields]"! !
!RoamBox class methodsFor: 'testing'!
bkScrollTest
"(RootMode new addSubMode: self bkScrollTest) startUp"
"This is to test the scrolling ability of a picture. The picture is first
draw on a subMode, and then the subMode is scrolled. Shan June 24,
1989 "
"mode displayObject relAdd: (self clientMode firstSubMode imageSize: 196 @ 100 window: (0@0 extent:1000@250))."
| rMode sMode sSMode sBar dispObj spline line rand |
rMode _ Mode new borderWidth: 0.
rMode displayObject absAdd: (Quadrangle region: (49@49 extent: 302@202) borderWidth: 1 borderColor: Form black insideColor: Form white).
sMode _ Simple origin: 50 @ 50 extent: 300 @ 200.
sSMode _ Simple origin: 0 @ 0 extent: 1000 @ 250.
dispObj _ sSMode displayObject.
dispObj boundingBox: (0@0 extent: 1000@250).
spline _ MMSSpline new.
spline form: (Form new extent: 3 @ 3) black.
rand _ Random new.
0 to: 25 do: [:n | spline add: 40 * n @ (rand next * 250) rounded].
dispObj absAdd: spline.
line _ MMSLine
from: 0 @ 125
to: 1000 @ 125
width: 4
color: Form darkGray.
dispObj absAdd: line.
dispObj insideColor: Form white. "This is necessary to make spline work."
sMode insideColor: Form white. "To avoid eraseing the bk"
sSMode borderWidth: 0.
sMode borderWidth: 0.
dispObj makeAbsoluteFaster.
rMode addSubMode: sMode.
sMode addSubMode: sSMode.
sBar _ RoamBox extent: 200 @ 18 clientMode: sMode.
sBar attachModeTo: rMode at: 50 @ 260.
sBar updateStyle: #continuous.
"Make reference points for roam demo."
rMode displayObject absAdd: (MMSLine from: 50@260 to: 50@260).
rMode displayObject absAdd: (MMSLine from: 250@360 to: 250@360).
^rMode resizeStyle: ResizeStyle stickFourCorners!
scrollTest
"self scrollTest"
| rMode sMode s1SMode sSMode sBar dispObj line |
rMode _ RootMode new.
sMode _ Simple origin: 50 @ 50 extent: 200 @ 200.
dispObj _ sMode displayObject.
line _ MMSLine
from: 0 @ 0
to: 500 @ 50
width: 2 @ 2
color: Form black.
dispObj relAdd: line.
sSMode _ Simple origin: 20 @ 20 extent: 100 @ 400.
sSMode insideColor: Form lightGray.
s1SMode _ Simple origin: 25 @ 120 extent: 400 @ 50.
s1SMode insideColor: Form gray.
rMode addSubMode: sMode.
sMode addSubMode: sSMode.
sMode addSubMode: s1SMode.
sBar _ RoamBox extent: 18@200 clientMode: sMode.
sBar attachModeTo: rMode at: 260@50.
sBar _ RoamBox extent: 200@18 clientMode: sMode.
sBar attachModeTo: rMode at: 50@260.
rMode startUp! !
SemanticObject subclass: #Marker
instanceVariableNames: ''
classVariableNames: ''
poolDictionaries: ''
category: 'Scroll-Shan'!
!Marker methodsFor: 'controller-msg'!
moveMarker: e
"Tracking the marker and communicate with the client. Shan June 20,
1989"
| oldDispB |
oldDispB _ mode displayBox.
mode controller moveFrameConstrained.
oldDispB ~= mode displayBox ifTrue: ["Maybe I should use a link instead."
mode superMode semanticObject markerMovedTo: mode displayBox]! !
!Marker methodsFor: 'MMS-initializations'!
setUpAppearance
"Shan June 20, 1989"
| dispObj |
super setUpAppearance.
dispObj _ mode displayObject.
dispObj insideColor: Form gray!
setUpController
"Shan June 20, 1989"
| ctrl erDict |
ctrl _ OpaqueController1 new.
erDict _ ctrl eventResponses deepCopy.
erDict at: #leftButtonDown put: #moveMarker:.
ctrl eventResponses: erDict.
mode controller: ctrl! !